package com.yuyou.activity.group.api.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import com.yuyou.activity.group.service.ActivityGroupSPConfig;
import com.yuyou.activity.util.exception.BusinessException;



public class BaseController {
	
	

	
    @InitBinder
    public void initBinder(WebDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        dateFormat.setLenient(false);
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    }
	
    
    protected void valAllClose(String projectCode) throws Exception{
		//结束时间配置
		if(ActivityGroupSPConfig.getConfig(projectCode).getAllClose().getTime()<new Date().getTime()){
			throw new BusinessException("项目已结束");
		}
		
    }
       

    
    

}
